<template>
    <h3>登录</h3>
    <table border="1">
        <tr>
            <td>用户名</td>
            <td><input type="text" v-model="info.UName"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" v-model="info.UPwd"></td>
        </tr>
       <tr>
            <td colopan="2">
               <input type="button" value="登录" @click="DL">
            </td>
        </tr>
    </table>
</template>


<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';

const info = ref({
    UName:'',
    UPwd:''
})

//登录
const DL = ()=>{
    axios.get("http://localhost:4611/api/Invest/Login",{
        params:{
            UName:info.value.UName,
            UPwd:info.value.UPwd
        }
    })
    .then(res=>{
        if(res.data>0){
            alert("登录成功")
            location.href="/Invest"
        }
        else if(res.data==-1){
            alert("用户名不存在")
        }
        else if(res.data==-2){
            alert("密码错误")
        }
        else if(res.data==-3){
            alert("必须是管理员")
        }
        else
        {
            alert("登录失败")
        }
    })
}


</script>